package com.sky.happygos.base;

import com.sky.happygos.model.RestMessage;

import retrofit2.Response;

/**
 * Created by qqqqqqq on 2017/4/17.
 */

public class Event<T> {
    public T data;
    public boolean isSuccess;

    public RestMessage error;

    public Event(){

    }

    public Event(T data,boolean isSuccess){
        this.isSuccess = isSuccess;
        this.data = data;
    }

    //handle  error
    public Event(Response response){
        this.isSuccess = false;
        if(response != null) {
            this.error = ErrorHandler.handler(response);
        }else{
            this.error = new RestMessage(-1,"Net error");
        }
    }



}
